/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package com.nxlv2.nomad.accessdb.services;

import com.nxlv2.nomad.accessdb.dao.IClientDao;
import com.nxlv2.nomad.accessdb.dao.IContactDao;
import com.nxlv2.nomad.accessdb.dao.jdbc.JdbcClientDao;
import com.nxlv2.nomad.accessdb.dao.jdbc.JdbcContactDao;
import com.nxlv2.nomad.businessobjects.Client;
import com.nxlv2.nomad.businessobjects.Contact;

/**
 *
 * @author Administrateur
 */
public class ContactServices {
    private static final IContactDao dao = new JdbcContactDao();    
    private static final IClientDao daoCl = new JdbcClientDao();    

    /**
     * 
     * @param contact
     * @param client
     * @throws ServiceException 
     */
    public void create(Contact contact, Client client) throws ServiceException {        
        dao.saveContact(contact);
        daoCl.lierContactAClient(contact, client);
    }
    
    /**
     * 
     * @param contact
     * @throws ServiceException 
     */
    public void update(Contact contact) throws ServiceException {
        dao.updateContact(contact);
    }
    
    /**
     * 
     * @param contact
     * @throws ServiceException 
     */
    public void delete(Contact contact) throws ServiceException {
        dao.deleteContact(contact.getIdAppli());
    }
    
    /**
     * 
     * @param id
     * @return
     * @throws ServiceException 
     */
    public Contact get(int id) throws ServiceException {
        return dao.findContactById(id);
    }
}
